package com.spl.seriallibrary.locker.handleresult.datatransfer;

import java.util.Observable;
import java.util.Observer;

public class DataObserver implements Observer {

    private IUpdataBox iUpdataBox;
    private ICommonDataObservable iCommonDataObservable;

    public void setiUpdataBox(IUpdataBox iUpdataBox) {
        this.iUpdataBox = iUpdataBox;
    }

    public void setiCommonDataObservable(ICommonDataObservable iCommonDataObservable) {
        this.iCommonDataObservable = iCommonDataObservable;
    }

    public interface IUpdataBox {
        void updataBox(BoxDataObservable boxDataObservable);
    }

    public interface ICommonDataObservable {
        void commonDataObservable(CommonDataObservable commonDataObservable);
    }


    @Override
    public void update(Observable o, Object arg) {
        if (o instanceof BoxDataObservable) {
            BoxDataObservable boxDataObservable = (BoxDataObservable) o;
            if (iUpdataBox != null) {
                iUpdataBox.updataBox(boxDataObservable);
            }
        }
        if (o instanceof CommonDataObservable) {
            CommonDataObservable commonDataObservable = (CommonDataObservable) o;
            if (iCommonDataObservable != null) {
                iCommonDataObservable.commonDataObservable(commonDataObservable);
            }
        }
    }
}
